import request from '@/utils/request'

// 查询菜品管理列表
export function listDish(query) {
  return request({
    url: '/dish/dish/list',
    method: 'get',
    params: query
  })
}

// 查询菜品管理详细
export function getDish(id) {
  return request({
    url: '/dish/dish/' + id,
    method: 'get'
  })
}

// 新增菜品管理
export function addDish(data) {

  console.log("dataJSON:::")
  console.log(data)
  return request({
    url: '/dish/dish',
    method: 'post',
    data: data
  })
}

// 修改菜品管理
export function updateDish(data) {
  return request({
    url: '/dish/dish',
    method: 'put',
    data: data
  })
}

// 删除菜品管理
export function delDish(id) {
  return request({
    url: '/dish/dish/' + id,
    method: 'delete'
  })
}

// 更改菜品管理状态
export function updateStatusDish(ids,dishStatus) {
  let url = '/dish/dish/updateStatus/?status=' + dishStatus;
  if (Array.isArray(ids)){
    ids.forEach(id =>{
      url += "&ids=" + id;
    });
  }else{
    url += "&ids=" + ids;
  }
  return request({
    url: url,
    method: 'put'
  });
}
